TDL-17512: Add missing tap-tester tests#134
Conversation
| # removed "abandoned_checkouts", as per the Doc: | ||
| # https://help.shopify.com/en/manual/orders/abandoned-checkouts?st_source=admin&st_campaign=abandoned_checkouts_footer&utm_source=admin&utm_campaign=abandoned_checkouts_footer#review-your-abandoned-checkouts | ||
| # abandoned checkouts are saved in the Shopify admin for three months. | ||
| # Every Monday, abandoned checkouts that are older than three months are removed from your admin. | ||
| return set(self.expected_metadata().keys()) - {"abandoned_checkouts"} |
There was a problem hiding this comment.
Add comments about the unavailability of the POST call with a reference link.
There was a problem hiding this comment.
Added comment in the test cases.
| if md_entry['breadcrumb'] != []: | ||
| actual_fields.append(md_entry['breadcrumb'][1]) | ||
| # Verify there are no duplicate/conflicting metadata entries. | ||
| self.assertEqual(len(actual_fields), len(set(actual_fields)), msg="There are duplicate entries in the fields of '{}' stream".format(stream)) |
There was a problem hiding this comment.
Add a comment about this assertion at the function(test_run()) level comment above.
There was a problem hiding this comment.
Added function comment.
| target_mark = second_min_bookmarks.get(stream, {"mark": None}) | ||
| target_value = next(iter(target_mark.values())) # there should be only one | ||
| # Verify by primary key values, that all records of the 2nd sync are included in the 1st sync since 2nd sync has a later start date. | ||
| self.assertTrue(primary_keys_sync_2.issubset(primary_keys_sync_1)) |
There was a problem hiding this comment.
Add a comment about this assertion at the function(test_run()) level comment above.
There was a problem hiding this comment.
Added function comment.
| for start_date, target_mark in zip((first_sync_start_date, second_sync_start_date), (first_sync_target_mark, second_sync_target_mark)): | ||
| target_value = next(iter(target_mark.values())) # there should be only one |
There was a problem hiding this comment.
Add a comment here about the addition of for loop.
| return return_value | ||
|
|
||
| @staticmethod | ||
| def get_credentials(original_credentials: bool = True): |
There was a problem hiding this comment.
It is already available in base.py, Any reason for redefining it?
There was a problem hiding this comment.
Updated the test case to use the function from base test file.
kspeer825
left a comment
There was a problem hiding this comment.
This is good work. I left one suggestion for the start date test. Also the abandoned_checkouts does not need to be removed. We periodically refresh that data using tooling outside of tap-tester.
| return set(self.expected_metadata().keys()) | ||
| # removed "abandoned_checkouts", as per the Doc: | ||
| # https://help.shopify.com/en/manual/orders/abandoned-checkouts?st_source=admin&st_campaign=abandoned_checkouts_footer&utm_source=admin&utm_campaign=abandoned_checkouts_footer#review-your-abandoned-checkouts | ||
| # abandoned checkouts are saved in the Shopify admin for three months. | ||
| # Every Monday, abandoned checkouts that are older than three months are removed from your admin. | ||
| # Also no POST call is available for this endpoint: https://shopify.dev/api/admin-rest/2022-01/resources/abandoned-checkouts | ||
| return set(self.expected_metadata().keys()) - {"abandoned_checkouts"} |
There was a problem hiding this comment.
Please put this stream back, we have internal tooling for generating these records outside of the base test suite.
There was a problem hiding this comment.
Included abandoned_checkouts stream
| self.start_date = self.get_properties().get("start_date") | ||
| self.store_1_streams = {'custom_collections', 'orders', 'products', 'customers', 'locations', 'inventory_levels', 'inventory_items', 'events'} | ||
| self.store_2_streams = {'abandoned_checkouts', 'collects', 'metafields', 'transactions', 'order_refunds', 'products', 'locations', 'inventory_levels', 'inventory_items', 'events'} | ||
| # removed 'abandoned_checkouts' from store 2 streams, as per the Doc: |
There was a problem hiding this comment.
Please put back, see previous comment
There was a problem hiding this comment.
Included abandoned_checkouts stream
| msg="The fields sent to the target are not the automatic fields" | ||
| ) | ||
|
|
||
| # Verify that all replicated records have unique primary key values. |
| if md_entry['breadcrumb'] != []: | ||
| actual_fields.append(md_entry['breadcrumb'][1]) | ||
| # Verify there are no duplicate/conflicting metadata entries. | ||
| self.assertEqual(len(actual_fields), len(set(actual_fields)), msg="There are duplicate entries in the fields of '{}' stream".format(stream)) |
| first_sync_start_date = self.get_properties()["start_date"] | ||
| second_sync_start_date = self.start_date | ||
|
|
||
| # loop over minimum bookmark and the start date/state file date for each syncs to verify |
There was a problem hiding this comment.
The original implementation here was very difficult to follow. These changes are helpful, but can this be updated to conform to current best practices? See https://github.com/singer-io/tap-helpscout/blob/ad2b6192a5f5fad8c5bd0573cb38bf38bd5962dd/tests/test_helpscout_start_date.py#L109-L122
There was a problem hiding this comment.
The first 2 assertions are already included in our test case at line no. 141 and 147. Added assertion of replication key-values synced is greater than or equal to the start date.
| for record_replication_key in record_replication_keys: | ||
| self.assertGreaterEqual(record_replication_key, start_date) |
There was a problem hiding this comment.
I think the try except and assertion above are unnecessary. The minimum replication key value is covered by this assertion.
There was a problem hiding this comment.
Removed unnecessary assertion.
Description of change
TDL-17512: Add missing tap-tester tests
QA steps
Risks
Rollback steps